﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            var username = login.UserName.Trim();
            var password = login.Password.Trim();

            var sql = string.Format("select * from Users where Username='{0}' and Password='{1}'", username, password);

            var dt = DbHelper.GetData(sql);

            if (dt.Rows.Count > 0)
            {
                //保存登录状态
                Session["Username"] = username;
                Session["userid"] = dt.Rows[0].ItemArray[0].ToString();


                //跳转默认首页
                Response.Redirect("Default.aspx");
            }

        }

    }
}